

-- scap_Device MIGRATION

SET IDENTITY_INSERT ScapDevices ON

INSERT INTO ScapDevices ( Id,Name,Connection,IPAddress,IPPort, Status)
SELECT ID,MachineAlias,ConnectType,IP,Port,0
FROM ZKTECO.dbo.Machines zk
WHERE zk.ID NOT IN (SELECT Id FROM ScapDevices)

SET IDENTITY_INSERT ScapDevices OFF

UPDATE ScapDevices SET
	 Name=zk.MachineAlias
	,Connection=zk.ConnectType
	,IPAddress=zk.IP
	,IPPort=zk.Port
FROM ZKTECO.dbo.Machines zk
WHERE zk.ID = ScapDevices.Id

--SELECT * FROM scap_Device